function Module(){
	this.editIndex = undefined;
	this.module = 'module';
	this.treeid = 'moduleTree';
	this.dilogid = 'moduleDialog';
	this.datagrid = 'moduleGrid';
	this.formid = 'moduleFrom';
	this.rootUrl = 'module/';
	this.saveUrl = 'update';
	this.deleteUrl = 'delete';
}

Module.prototype.MsgResponse = {
	'success' : '操作成功',
	'error' : '操作失败'
};
Module.prototype.loadForm = function (data) {
	$('#' + this.formid).form('load', data);
};
Module.prototype.reloadDatagrid = function () {
	$('#' + this.datagrid).datagrid('reload');
};
// 弹窗操作区********************************BEGIN
Module.prototype.closeDilog = function (){
	$('#' + this.dilogid).dialog('close');
};
Module.prototype.openDilog = function (){
	$('#' + this.dilogid).dialog('open');
	$('#' + this.formid).form('clear');
	$('#' + this.formid).form('reset');
};
Module.prototype.add = function () { this.openDilog(); };
Module.prototype.cancel = function () { this.closeDilog(); };
Module.prototype.edit = function (index) {
	if (index != undefined) {
		$('#' + this.datagrid).datagrid('selectRow', index);
	}
	var selections = $('#' + this.datagrid).datagrid('getSelections');
	if (selections.length == 1) {
		this.openDilog();
		this.loadForm(selections[0]);
	} else {
		Common.Util.showMessager("未选择操作的数据或选择了多条操作数据");
	}
};
// 弹窗操作区********************************END
Module.prototype.deleted = function (index) {
	if (index != undefined) {
		$('#' + this.datagrid).datagrid('selectRow', index);
	}
	var o = this;
	Common.Util.sendGridDataIds(o.datagrid, o.rootUrl + o.deleteUrl,
		function (data, textStatus, jqXHR) {
			if (data.status) {
				o.reloadDatagrid();
			} else {
				Common.Util.showMessager(data.msg || o.MsgResponse.error);
			}
		},
		function (XMLHttpRequest, textStatus, errorThrown) {
			Common.Util.showMessager(o.MsgResponse.error);
		}
	);
};
Module.prototype.save = function () {
	var o = this;
	Common.Util.submitForm(o.formid, o.rootUrl + o.saveUrl,
		function (data, textStatus, jqXHR) {
			if (data.status) {
				o.reloadDatagrid();
				o.closeDilog();
			} else {
				Common.Util.showMessager(data.msg || o.MsgResponse.error);
			}
		},
		function (XMLHttpRequest, textStatus, errorThrown) {
			Common.Util.showMessager(o.MsgResponse.error);
		}
	);
};

/**
 * 操作格式化
 * @param {} value
 * @param {} rowData
 * @param {} index
 * @return {}
 */
Module.prototype.operationFormatter = function (value, rowData, index) {
	var html = '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="module.edit(' + index + ');">编辑</a>&nbsp;';
	return html + '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="module.deleted(' + index + ');">删除</a>';
};